package com.xhs.controller;

import com.xhs.design.factory.LoginFactory;
import com.xhs.dto.request.LoginFactoryRequest;
import com.xhs.message.ReturnResult;
import com.xhs.service.FactoryLoginService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @desc: 工厂模式
 * @projectName: tools-parent
 * @author: xhs
 * @date: 2022/12/4 22:34
 * @version: JDK 1.8
 */
@RestController
@RequestMapping("/factory")
public class FactoryController {

    /**
     * 登录接口
     *
     * @param loginRequest
     * @return
     */
    @PostMapping("/login")
    public ReturnResult<String> login(@RequestBody LoginFactoryRequest loginRequest) {
        FactoryLoginService myLogin = LoginFactory.getLogin(loginRequest);
        // 登录
        String login = myLogin.login(loginRequest);
        return ReturnResult.success(login);
    }
}
